package com.etlmaster.executor.steps.control;

import com.etlmaster.executor.utils.DataCollectionUtils;

public class AssignTimeStampProcessor extends AssignProcessor{

	@Override
	public int process(AssignStepMeta meta) {
		String current_timestamp="";
		expression = expression.replaceAll("(\r\n|\r|\n|\n\r)","");
		String[] expressionArr = expression.split(";");
		for (int i = 0; i < expressionArr.length; i++) {
			int pos=expressionArr[i].indexOf("in");
			String format = expressionArr[i].substring(pos+2).trim();
			if(format!=null){
				current_timestamp=DataCollectionUtils.getCurrentTimestampByFormate(format);
			}
			meta.getStepState().getReturnValue().put(expressionArr[i].substring(0,pos).trim(), current_timestamp);
			meta.log("DEBUG","赋值成功 {} -> {}",expressionArr[i].substring(0,pos),current_timestamp);
		}

		return 0;
	}

}
